<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>双赢赛车</title>
<meta content="user-scalable=no,maximum-scale=1.0" id="viewport"
	name="viewport"/>
<meta name='Robots' content='noindex,nofollow'/>
<link href="/public/wx.css?2" type="text/css" rel="stylesheet" />
</head>
<body>
<style>
* {
	margin: 0;
	padding: 0;
}
</style>
	<div class="frameTOP">
	<!--     allowtransparency='yes'-->
		<iframe id='ifarms' scrolling="no" marginwidth='0' marginheight='0' width="100%"  border='0'   class="ifarms" frameborder='no' ></iframe>
		<div style="width:100%;height: 650px;position: absolute;top: 0;left: 0;z-index: 9999; "></div>
		<div class="neirong" style="display: none;">
			<table id='tables' border='0' cellpadding='0' cellspacing='0' width="70%">
			</table>
		</div>
	</div>
		<!-- 信息下注 -->

	<!--聊天主体  -->
	<div class="leftdiv">
		<img src="<?php echo $user[0]['headpic'];?>" style="margin-top: 0;" />
		<img src="/public/1.png"  onclick="showframeRIGHTH('fT');"/> 
		<img src="/public/2.png" onclick="showframeRIGHTH('frameRIGHT');" /> 
		<img src="/public/3.png"  onclick="showframeRIGHTH('jilu');" />
		<img src="/public/4.png" onclick="showframeRIGHTH2('ifarms');" />
		<img src="/public/5.png" onclick="showframeRIGHTH2('neirong');" /> 
		<img src="/public/6.png" onclick="location=location" /> 
		<img src="/public/7.png" onclick="showframeRIGHTH('guize');" />
		<img src="/public/10.png" onclick="showframeRIGHTH('cz');" />
	</div>
	<div id="frameRIGHTH">
		<div class='frameRIGHT' >
			<div class="user_messages">
				<input type="text" id='Message' /> <span class="sendemaill">发 送</span>
				<span class="usermoney">
					<p>
						剩余点数：<b id="rmb2"><?php echo $user[0]['money'];?></b>点
					</p>
					<p>
						线上人数：<b id="zx2" >0</b>人
					</p>
				</span>
			</div>
			<div class="rightdiv">
			 <?php if($msg2):?>
	       
	               <?php foreach ($msg2 as $k=>$v):?>
	                       <?php if($v['senderID']!=0):?>
	                           <div class=saidleft><img  src="<?php echo  $v['headpic'];?>" /><div class=tousaid><span class=tousaid1><?php echo  $v['nickname'];?></span>&nbsp;&nbsp;<span class=tousaid2><?php echo date('H:i:s',$v['gtime'])?></span></div><div class=tsf><b></b><span class=neirongsaid><?php echo $v['what'];?></span></div></div>
	                       <?php elseif($v['jqrfalg']==1):?>
	                           <div class=saidleft><img  src="<?php echo  $v['pic'];?>" /><div class=tousaid><span class=tousaid1><?php echo  $v['niname'];?></span>&nbsp;&nbsp;<span class=tousaid2><?php echo date('H:i:s',$v['gtime'])?></span></div><div class=tsf><b></b><span class=neirongsaid><?php echo $v['what'];?></span></div></div>
	                       <?php else:?>
	                           <div class=saidright><img  src="/public/gl.jpg" /><div class=tousaidl><span class=tousaid2 ><?php echo date('H:i:s',$v['gtime'])?></span>&nbsp;&nbsp;<span class=tousaid1>系统GM</span></div><div class='ts' style="min-width:60%;"> <b style='border-color:transparent  transparent transparent #98E165;'></b><span class='neirongsaidl' style="background-color: #98E165;max-width: 85%"><?php echo $v['what'];?></span></div></div>
	                       <?php endif;?>
	               <?php endforeach;?>
              <?php endif;?>

			</div>
		</div>
        
        
        <div class='fT'  style="display: none;">
			<div class="user_messages">
				<input type="text" id='kfs' /> <span  id="sendkf">发 送</span>
				<span class="usermoney">
					<p>
						剩余点数：<b id="rmb1"><?php echo $user[0]['money'];?></b>点
					</p>
					<p>
						线上人数：<b id="zx1">0</b>人
					</p>
				</span>
			</div>
			<div class="kfcs" >
			
			 <?php if($msg):?>
	       
	               <?php foreach ($msg as $k=>$v):?>
	                       <?php if($v['senderID']!=0):?>
	                           <div class=saidleft><img  src="<?php echo  $user[0]['headpic'];?>" /><div class=tousaid><span class=tousaid1><?php echo  $user[0]['nickname'];?></span>&nbsp;&nbsp;<span class=tousaid2><?php echo date('H:i:s',$v['gtime'])?></span></div><div class=tsf><b></b><span class=neirongsaid><?php echo $v['what'];?></span></div></div>
	                       <?php else :?>
	                           <div class=saidright><img  src="/public/kefu.jpg" /><div class=tousaidl><span class=tousaid2 ><?php echo date('H:i:s',$v['gtime'])?></span>&nbsp;&nbsp;<span class=tousaid1>客服</span></div><div class='ts' style="min-width: 60%;"> <b></b><span class='neirongsaidl' ><?php echo $v['what'];?></span></div></div>
	                       <?php endif;?>
	               <?php endforeach;?>
              <?php endif;?>
			
			</div>
		</div>
        <!-- style="display: none;"  -->
        <div class="jilu"  style="display: none;">
           <p class="jilup">会员: <?php echo $user[0]['nickname'];?> &nbsp;&nbsp;  点数: <b id="rmb3"><?php echo $user[0]['money'];?></b> &nbsp;&nbsp; 代理: <?php echo $dlname?$dlname:'GM';?> &nbsp;&nbsp;  编号: <?php echo 'WKF'.$user[0]['ID'];?> </p>
           
           <p class="jilup2">[<a><?php echo $t1;?></a>]&nbsp;&nbsp; [<a><?php echo $t2;?></a>]&nbsp;&nbsp; [<a><?php echo $t3;?></a>]&nbsp;&nbsp; [<a>历史</a>]</p>
             <table id="mutable" border='1' cellpadding='0' cellspacing='0' width="85%" >
                
                
            </table>
        </div>
        
		<div class="guize" style="display: none;">
            <?php echo $ct;?>
        </div>
        
        <div class="cz" style="display: none;">
            <?php echo $cz;?>
        </div>
	</div>
	 
</body>
</html>
<script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload=function()
{
	$('.logo').css('height',$('.logo').outerWidth()/2);
	$('.logo').css('line-height',$('.logo').outerWidth()/2+'px');
	
	var h=document.documentElement.clientHeight;

	 var ifa=document.getElementById('ifarms');
	ifa.style.height='650px';
	//ifa.src='http://<?php echo $_SERVER['HTTP_HOST'];?>/tet/index.html';

	 var myDate = new Date();
	 var h=myDate.getHours();
	// ifa.src="http://m.dz99.com/pk10zb.html";
	  if(h>=0 && h<=4){
		  var xs=ifa.src;
		 // alert(xs);
		  if( xs !='http://<?php echo $_SERVER['HTTP_HOST'];?>/ft/ft.html'){
			  ifa.src='http://<?php echo $_SERVER['HTTP_HOST'];?>/ft/ft.html';
		  }
	  }else{
		  var xs=ifa.src;
		  if(xs!='http://<?php echo $_SERVER['HTTP_HOST'];?>/tet/index.html'){
				
			  ifa.src='http://<?php echo $_SERVER['HTTP_HOST'];?>/tet/index.html';
		  }
	  }
	



	
	var picts='<?php echo $user[0]['headpic'];?>';
	var nickname='<?php echo $user[0]['nickname'];?>';
	var ID='<?php echo $user[0]['ID'];?>';
	var socket = new WebSocket('ws://<?php echo $GLOBALS['C']['IPDIR'];?>'); 

	socket.onopen = function(event) {
		  // 发送一个初始化消息
	
		var sendMessage={
				'code':1,
				'status':'login',
				'content':null,
				'from':ID,
				'TO':0,
				'pic':picts,
				'nickname':nickname
		};
		 var str=JSON.stringify(sendMessage);
		  socket.send(str);
		  
		  // 监听消息
		  	socket.onmessage = function(event) {
			  	 var obj = eval('(' + event.data + ')');
				  
			  	if(obj.code==1){
			  		addxitong(obj.pic,obj.nickname,obj.content,obj.time);
					if(obj.status=='fp'){
						var ifa=document.getElementById('ifarms');
						ifa.window.location.reload();
					}

			  		//console.log('fp',obj);
				}else if(obj.code==2){
			  		addtouzhu(obj.pic,obj.nickname,obj.content,obj.time);
			  		console.log('touzhu',obj);
				}else if(obj.code==3){
					addxitong1(obj.pic,obj.nickname,obj.content,obj.time);
				}else if(obj.code==4){
					 if(obj.F=='C'){
						 kefu1(obj.pic,obj.nickname,obj.content,obj.time);
					 }else{
						 kefu2(obj.pic,obj.nickname,obj.content,obj.time);
					 }
				}else if(obj.code==6){
					addxitong3(obj.pic,obj.nickname,obj.content,obj.time);
					setmoney(obj.money);
					console.log('touzhu',obj);
					
				}else if(obj.code==7){
					$("#zx2").html('');
					$("#zx1").html('');
					$("#zx1").html(obj.content);
					$("#zx2").html(obj.content);
				}
			}; 
			//监听Socket的关闭
			socket.onclose = function(event) { 
			  //console.log('Client notified socket has closed',event); 
			}; 
	};
	
	$(".sendemaill").click(function(){
		 var MES=$("#Message").val();
		 if(MES){
			var sendMessage={
					'code':2,
					'status':'message',
					'content':MES,
					'from':ID,
					'TO':0,
					'pic':picts,
					'nickname':nickname
			};
			 var str=JSON.stringify(sendMessage);
			  socket.send(str); 
			 $("#Message").val('');
		 } 
	});

	$("#sendkf").click(function(){
		
		var MES=$("#kfs").val();
		 if(MES){
			var sendMessage={
					'code':4,/*客服消息*/
					'status':'gm',
					'content':MES,
					'from':ID,
					'TO':0,
					'pic':picts,
					'nickname':nickname
			};
			 var str=JSON.stringify(sendMessage);
			  socket.send(str); 
			 $("#kfs").val('');
		 } 

	});
	
	 document.onkeydown=function(event){
         var e = event || window.event || arguments.callee.caller.arguments[0];
          if(e && e.keyCode==13){ // enter 键
        	  var MES=$("#Message").val();
        	  var MES2=$("#kfs").val();
        	  if(MES){
        		  var sendMessage={
        					'code':2,
        					'status':'message',
        					'content':MES,
        					'from':ID,
        					'TO':0,
        					'pic':picts,
        					'nickname':nickname
        			};
            	  
        		  var str=JSON.stringify(sendMessage);
        		  socket.send(str); 
      			 $("#Message").val('');
      		 }

        	  if(MES2){
        		  var sendMessage={
        					'code':4,/*客服消息*/
        					'status':'gm',
        					'content':MES2,
        					'from':ID,
        					'TO':0,
        					'pic':picts,
        					'nickname':nickname
        			};
        			 var str=JSON.stringify(sendMessage);
        			  socket.send(str); 
        			 $("#kfs").val('');
      		 }
         }
     }; 
     setInterval(addlishi,3000);
     usedate(0,ID);
	 $(".jilup2 a").click(function(){
		var indexs=$(this).index();
		usedate(indexs,ID);
	 });
	
	
}




function setmoney(money)
{
	$("#rmb1").html('');
	$("#rmb3").html('');
	$("#rmb2").html('');
	$("#rmb1").html(money);
	$("#rmb2").html(money);
	$("#rmb3").html(money);
}



function usedate(indexs,ID)
{
	indexs?indexs:0;
	$("#mutable").html("");
	$("#mutable").html("<tr><th>#</th><th>时间</th><th>操作</th><th>备注</th><th>进项</th><th>出项</th><th>余点</th></tr>");
	var xi=1;
	$.ajax({
         type: "POST",
         url: "/index.php?G=d/findM",
         data:  {"i":indexs,'id':ID},
         success:function(data){
            	var str1=eval("("+data+")");
            	
            	if(str1){
            		for(obj2 in str1)
    				{
            			$("#mutable").append("<tr><td colspan='7'>"+obj2+"</td></tr>");

        				var str=str1[obj2];
            			//console.log(str[0]);
						for(obj in str){
							var mx='';
							var mx2='';
							if(str[obj].type==1){
								mx=str[obj].money;
							}else{
								mx2=str[obj].money;
							}
							if(str[obj].cx==1 && str[obj].dit!=1){
	        					$("#mutable").append("<tr><td width='8%'>"+xi+".</td><td width='17%'>"+str[obj].gtime+"</td><td width='10%'>"+str[obj].status+"</td><td width='40%'>"+str[obj].remark+"<a class='cxjil' ai="+str[obj].ID+">撤销</a></td><td width='7.5%' >"+mx+"</td><td width='7.5%'>"+mx2+"</td><td  width='10%'>"+str[obj].new_money+"</td></tr>");
	            			}else{
	                			if(str[obj].dit==1){
	                				$("#mutable").append("<tr><td width='8%'>"+xi+".</td><td width='17%'>"+str[obj].gtime+"</td><td width='10%'>"+str[obj].status+"</td><td width='40%'><a style='color:red'>本次竞猜已经撤回！</a>"+str[obj].remark+"</td><td width='7.5%' >"+mx+"</td><td width='7.5%'>"+mx2+"</td><td  width='10%'>"+str[obj].new_money+"</td></tr>");
	                			}else{
	                    			
	        						$("#mutable").append("<tr><td width='8%'>"+xi+".</td><td width='17%'>"+str[obj].gtime+"</td><td width='10%'>"+str[obj].status+"</td><td width='40%'>"+str[obj].remark+"</td><td width='7.5%' >"+mx+"</td><td width='7.5%'>"+mx2+"</td><td  width='10%'>"+str[obj].new_money+"</td></tr>");
	                			}
	            			}

							xi++;
						}
            			
        				
                		
    				};
    				$(".cxjil").on('click',function(){
							if(confirm('确定要撤回本次竞猜结果么！')){
								var tid=$(this).attr('ai');
								$.ajax({
							         type: "POST",
							         url: "/index.php?G=d/cexiao",
							         data: {'tid':tid,'ID':ID},
							         success:function(data){
							            	alert(data);
							            	usedate(0,ID)
							         }
							    });
							}
							
					});
    				
            	}else{
            		$("#mutable").append("<tr><td colspan='5'>无更多资料，最多显示300条信息</td></tr>");
                }
            	
         } });
	
}
function addlishi()
{

	 
	 var ifa=document.getElementById('ifarms');
	 var myDate = new Date();
	 var h=myDate.getHours();
	// ifa.src="http://m.dz99.com/pk10zb.html";
	  if(h>=0 && h<=4){
		  var xs=ifa.src;
		 // alert(xs);
		  if( xs !='http://<?php echo $_SERVER['HTTP_HOST'];?>/ft/ft.html'){
			  ifa.src='http://<?php echo $_SERVER['HTTP_HOST'];?>/ft/ft.html';
		  }
	  }else{
		  var xs=ifa.src;
		  if(xs!='http://<?php echo $_SERVER['HTTP_HOST'];?>/tet/index.html'){
				
			  ifa.src='http://<?php echo $_SERVER['HTTP_HOST'];?>/tet/index.html';
		  }
	  }

	var colorsF = ['#FFD700','#008BFF','#4D4D4D','#FF7300','#6EF3F3','#5301FF','#D7D7D7','#FF0000','#760000','#28C200'];
	
	 $.ajax({
         type: "GET",
         url: "/index.php?G=d/data",
         data: '',
         success:function(data){
            	var str=eval("("+data+")");
            	$("#tables").html('<tr><th>期号</th><th>开奖时间</th><th>开奖号码</th><th>特码</th></tr>');
				for(obj in str)
				{
                    var f=str[obj].numbers.split(',');
                    var lh=str[obj].lh.split('');
                    var tm=str[obj].tm.split(',');
					var MF=new Array();
                    for(of in f){
                    	MF.push(colorsF[parseInt(f[of])-1]);
                    }
                    if(obj%2==0){
                    	$("#tables").append("<tr class='t1'><td>"+str[obj].issue+"</td><td width='18%'>"+str[obj].gtime+"</td> <td width='58%'> <p class='p1p'><span style='background-color:"+MF[0]+"'>"+f[0]+"</span><span style='background-color:"+MF[1]+"'>"+f[1]+"</span><span style='background-color:"+MF[2]+"'>"+f[2]+"</span><span style='background-color:"+MF[3]+"'>"+f[3]+"</span><span style='background-color:"+MF[4]+"'>"+f[4]+"</span><span style='background-color:"+MF[5]+"'>"+f[5]+"</span><span style='background-color:"+MF[6]+"'>"+f[6]+"</span><span style='background-color:"+MF[7]+"'>"+f[7]+"</span><span style='background-color:"+MF[8]+"'>"+f[8]+"</span><span style='background-color:"+MF[9]+"'>"+f[9]+"</span></p>  <p class='p2p'><span>"+lh[0]+"</span><span>"+lh[1]+"</span><span>"+lh[2]+"</span><span>"+lh[3]+"</span><span>"+lh[4]+"</span></p></td><td><p><span>"+tm[0]+"</span><span>"+tm[1]+"</span><span>"+tm[2]+"</span><span>"+tm[3]+"</span><span>"+tm[4]+"</span></p></td></tr>");
                   }else{
                   		$("#tables").append("<tr class='t2'><td>"+str[obj].issue+"</td><td width='18%'>"+str[obj].gtime+"</td> <td width='58%'> <p class='p1p'><span style='background-color:"+MF[0]+"'>"+f[0]+"</span><span style='background-color:"+MF[1]+"'>"+f[1]+"</span><span style='background-color:"+MF[2]+"'>"+f[2]+"</span><span style='background-color:"+MF[3]+"'>"+f[3]+"</span><span style='background-color:"+MF[4]+"'>"+f[4]+"</span><span style='background-color:"+MF[5]+"'>"+f[5]+"</span><span style='background-color:"+MF[6]+"'>"+f[6]+"</span><span style='background-color:"+MF[7]+"'>"+f[7]+"</span><span style='background-color:"+MF[8]+"'>"+f[8]+"</span><span style='background-color:"+MF[9]+"'>"+f[9]+"</span></p>  <p class='p2p'><span>"+lh[0]+"</span><span>"+lh[1]+"</span><span>"+lh[2]+"</span><span>"+lh[3]+"</span><span>"+lh[4]+"</span></p></td><td><p><span>"+tm[0]+"</span><span>"+tm[1]+"</span><span>"+tm[2]+"</span><span>"+tm[3]+"</span><span>"+tm[4]+"</span></p></td></tr>");
                    }

                    $(".p2p span").each(function(i){
    					if($(this).html()=='龙'){
    						$(this).css('color','#FF0000');
    					}else{
    						$(this).css('color','#00CCFF');
    					}
    				}); 
    				 $(".p2p").parent().next().find('span').each(function(i){
    					if($(this).html()=='小'){
    						$(this).css('color','#FF0000');
    					}else if($(this).html()=='大'){
    						$(this).css('color','#00CCFF');
    					}else if($(this).html()=='双'){
    						$(this).css('color','#FF0000');
    					}else if($(this).html()=='单'){
    						$(this).css('color','#00CCFF');
    					}else if($(this).html()=='闲'){
    						$(this).css('color','#FF0000');
    					}else if($(this).html()=='庄'){
    						$(this).css('color','#00CCFF');
    					}else{
    						$(this).css('color','white');
    					}
    					
    				 });
                    
				};
         } });
/* set */
	 $.ajax({
         type: "GET",
         url: "/index.php?G=d/getmoney",
         data: {'i':<?php echo $user[0]['ID'];?>},
         success:function(data){
             if(data>0){
                 console.log(data);
            	 setmoney(data);
             }  
         }
     });


     
}


function kefu1(picts,nickname,strs,time)
{
	 $(".kfcs").prepend("<div class=saidright><img  src="+picts+" /><div class=tousaidl><span class=tousaid2 >"+time+"</span>&nbsp;&nbsp;<span class=tousaid1>"+nickname+"</span></div><div class=ts> <b></b><span class=neirongsaidl>"+strs+"</span></div></div>");  		
}

function kefu2(picts,nickname,strs,time)
{

	 $(".kfcs").prepend("<div class=saidleft><img  src="+picts+" /><div class=tousaid><span class=tousaid1>"+nickname+"</span>&nbsp;&nbsp;<span class=tousaid2>"+time+"</span></div><div class=tsf><b></b><span class=neirongsaid>"+strs+"</span></div></div>"); 
}


function addxitong(picts,nickname,strs,time)
{
	 $(".rightdiv").prepend("<div class=saidright><img  src="+picts+" /><div class=tousaidl><span class=tousaid2 >"+time+"</span>&nbsp;&nbsp;<span class=tousaid1>"+nickname+"</span></div><div class=ts> <b></b><span class=neirongsaidl>"+strs+"</span></div></div>");  		
}
function addxitong1(picts,nickname,strs,time)
{
	 $(".rightdiv").prepend("<div class=saidright><img  src="+picts+" /><div class=tousaidl><span class=tousaid2 >"+time+"</span>&nbsp;&nbsp;<span class=tousaid1>"+nickname+"</span></div><div class=ts> <b style='border-color:transparent  transparent transparent #FFBBBB;'></b><span class=neirongsaidl style='background-color: #FFBBBB;' >"+strs+"</span></div></div>");  		
}

function addxitong3(picts,nickname,strs,time)
{
	 $(".rightdiv").prepend("<div class=saidright><img  src="+picts+" /><div class=tousaidl><span class=tousaid2 >"+time+"</span>&nbsp;&nbsp;<span class=tousaid1>"+nickname+"</span></div><div class='ts' style='min-width: 60%;'> <b style='border-color:transparent  transparent transparent #98E165;'></b><span class=neirongsaidl style='background-color:#98E165;max-width: 100%'>"+strs+"</span></div></div>");  		
}


function addtouzhu(picts,nickname,strs,time)
{
	 $(".rightdiv").prepend("<div class=saidleft><img  src="+picts+" /><div class=tousaid><span class=tousaid1>"+nickname+"</span>&nbsp;&nbsp;<span class=tousaid2>"+time+"</span></div><div class=tsf><b></b><span class=neirongsaid>"+strs+"</span></div></div>"); 
}



function showframeRIGHTH(cla)
{
	nones();
	if(cla=='jilu'){
		 usedate(0,<?php echo $user[0]['ID'];?>);
	}
	$('.'+cla).show();
}

function nones()
{
	$(".frameRIGHT").hide();
	$(".guize").hide();
	$(".fT").hide();
	$(".jilu").hide();
	$(".cz").hide();
}

function showframeRIGHTH2(cla)
{
	nones2();
	$('.'+cla).show();
}
function nones2()
{
	$("#ifarms").hide();
	$(".neirong").hide();
}
</script>

